-- @owner: @li-xin12345
-- @date: 2022/02/17
-- @testpoint: 将clob和触发器结合，成功

--step1:建表;expect:成功
drop table if exists t_ustore_datatype_clob_0022;
create table t_ustore_datatype_clob_0022(c_id int,b_clob clob) with (storage_type=ustore);

--step2:插入数据;expect:插入数据成功
insert into t_ustore_datatype_clob_0022 values(1,'35466');
insert into t_ustore_datatype_clob_0022 values(2,'3546213457869708234444479806');
insert into t_ustore_datatype_clob_0022 values(3,'3546213457864444479806');
insert into t_ustore_datatype_clob_0022 values(4,'35463457686543122453536');
insert into t_ustore_datatype_clob_0022 values(5,'354621345784533669708234444479806');
insert into t_ustore_datatype_clob_0022 values(6,'354621345743567378567864444479806');
insert into t_ustore_datatype_clob_0022 values(7,'100000');
insert into t_ustore_datatype_clob_0022 values(8,'101000');
insert into t_ustore_datatype_clob_0022 values(9,'1000100');
insert into t_ustore_datatype_clob_0022 values(10,'c4711a1097876cc');
insert into t_ustore_datatype_clob_0022 values(11,'');
insert into t_ustore_datatype_clob_0022 values(12,null);

--step3:将clob和触发器结合;expect:成功
create or replace function tri_func_ustore_datatype_clob_0022() returns trigger as
$$
declare
declare  cc_clob clob;
begin
 update t_ustore_datatype_clob_0022 set b_clob= b_clob || '35466' where c_id=1;
 select b_clob into cc_clob from t_ustore_datatype_clob_0022 where c_id=1;
 raise info '%',('result:'||cc_clob);
return new;
end;
$$ language plpgsql;
/
create  trigger trigger_ustore_datatype_clob_0022 before insert
on t_ustore_datatype_clob_0022 for each row
execute procedure tri_func_ustore_datatype_clob_0022();
/
insert into t_ustore_datatype_clob_0022 values(1,'35466');
select * from t_ustore_datatype_clob_0022 where c_id=1;

--step4:环境清理;expect:成功
drop trigger trigger_ustore_datatype_clob_0022 on t_ustore_datatype_clob_0022;
drop table  t_ustore_datatype_clob_0022;
drop function tri_func_ustore_datatype_clob_0022;